File: README.md

package info (click to toggle)
golang-opentelemetry-contrib 0.56.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,884 kB
  • sloc: makefile: 278; sh: 211; sed: 1
file content (69 lines) | stat: -rw-r--r-- 2,375 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# OpenTelemetry AWS Lambda Resource Detector for Golang

[![Go Reference][goref-image]][goref-url]
[![Apache License][license-image]][license-url]

This module detects resource attributes available in AWS Lambda.

## Installation

```bash
go get -u go.opentelemetry.io/contrib/detectors/aws/lambda
```

## Usage

Create a sample Lambda Go application such as below.

```go
package main

import (
	"github.com/aws/aws-lambda-go/lambda"
	sdktrace "go.opencensus.io/otel/sdk/trace"
	lambdadetector "go.opentelemetry.io/contrib/detectors/aws/lambda"
)

func main() {
	detector := lambdadetector.NewResourceDetector()
	res, err := detector.Detect(context.Background())
	if err != nil {
		fmt.Printf("failed to detect lambda resources: %v\n", err)
	}

	tp := sdktrace.NewTracerProvider(
		sdktrace.WithResource(res),
	)
	lambda.Start(<some lambda handler>)
}
```

Now your `TracerProvider` will have the following resource attributes and attach them to new spans:

| Resource Attribute | Example Value |
| --- | --- |
| `cloud.provider` | aws
|`cloud.region` | us-east-1 
|`faas.name` | MyLambdaFunction 
|`faas.version` | $LATEST
|`faas.instance` | 2021/06/28/[$LATEST]2f399eb14537447da05ab2a2e39309de
|`faas.max_memory`| 128

Of note, `faas.id` and `cloud.account.id` are not set by the Lambda resource detector because they are not available outside a Lambda invocation. For this reason, when using the AWS Lambda Instrumentation these attributes are set as additional span attributes.

## Useful links

- For more on FaaS attribute conventions, visit <https://opentelemetry.io/docs/specs/semconv/faas/faas-spans/>
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
- For more about OpenTelemetry Go: <https://github.com/open-telemetry/opentelemetry-go>
- For help or feedback on this project, join us in [GitHub Discussions][discussions-url]

## License

Apache 2.0 - See [LICENSE][license-url] for more information.

[license-url]: https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/LICENSE
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
[goref-image]: https://pkg.go.dev/badge/go.opentelemetry.io/contrib/detectors/aws/lambda.svg
[goref-url]: https://pkg.go.dev/go.opentelemetry.io/contrib/detectors/aws/lambda
[discussions-url]: https://github.com/open-telemetry/opentelemetry-go/discussions