Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flyer103/otel-demo
OpenTelemetry golang demo
https://github.com/flyer103/otel-demo
golang observability opentelemetry opentelemetry-go
Last synced: 3 months ago
JSON representation
OpenTelemetry golang demo
- Host: GitHub
- URL: https://github.com/flyer103/otel-demo
- Owner: flyer103
- License: apache-2.0
- Created: 2021-02-24T09:33:03.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-24T10:57:42.000Z (almost 4 years ago)
- Last Synced: 2024-09-28T14:22:15.009Z (3 months ago)
- Topics: golang, observability, opentelemetry, opentelemetry-go
- Language: Go
- Homepage:
- Size: 3.72 MB
- Stars: 45
- Watchers: 5
- Forks: 15
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Overview
This is a golang example that uses
[OpenTelemetry](https://opentelemetry.io) to fulfill observability.# Usage
## Build
```shell
$ make build-demo
```## Help
```shell
$ ./release/demo -h
```## Run and exports metrics to stdout
```shell
$ ./release/demo --use-stdout-exporter
```## Run and exports metrics to [AlibabaCloud SLS](https://www.aliyun.com/product/sls)
1. Download `otel-contrib-collector` from
[opentelemetry-collector-contrib releases](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases)
and make it executable and searchable from `$PATH`.2. Prepare a yaml file of collector configuration:
```yaml
receivers:
otlp:
protocols:
grpc:
endpoint: "0.0.0.0:4317"processors:
batch:
send_batch_size: 10000
send_batch_max_size: 11000
timeout: 10s
metricstransform:
transforms:
- include: request
action: update
new_name: demo_request
- include: throughput
action: update
operations:
- action: add_label
new_label: my_label
new_value: demoexporters:
alibabacloud_logservice/metrics:
# LogService's Endpoint, https://www.alibabacloud.com/help/doc-detail/29008.htm
# for AlibabaCloud Kubernetes(or ECS), set {region-id}-intranet.log.aliyuncs.com, eg cn-hangzhou-intranet.log.aliyuncs.com;
# others set {region-id}.log.aliyuncs.com, eg cn-hangzhou.log.aliyuncs.com
endpoint: "cn-hangzhou.log.aliyuncs.com"
# LogService's Project Name
project: ""
# LogService's Logstore Name
logstore: ""
# AlibabaCloud access key id
access_key_id: ""
# AlibabaCloud access key secret
access_key_secret: ""
file:
path: ./metrics.jsonservice:
pipelines:
metrics:
receivers: [otlp]
processors: [batch, metricstransform]
exporters: [alibabacloud_logservice/metrics, file]
```You can find the detailed configuration of AlibabaCloud SLS [here](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/alibabacloudlogserviceexporter).
3. Run `otelcontribcol`
```shell
$ otelcontribcol --config /PATH/TO/
```4. Run app
```shell
$ ./release/demo --use-stdout-exporter=false --use-collector --collector-otlp-endpoint 0.0.0.0:4317
```