GithubHelp home page GithubHelp logo

alexey-slivkin / example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ogen-go/example

0.0 0.0 0.0 263 KB

Sample project with client, server, prometheus and jaeger

License: Apache License 2.0

Shell 1.76% Go 96.48% Makefile 1.76%

example's Introduction

example

Example for server and client with graceful shutdown and open telemetry exporters for prometheus and jaeger.

Server

Environmental variables

Name Value Description
OTEL_SERVICE_NAME api OpenTelemetry service name
OTEL_RESOURCE_ATTRIBUTES service.namespace=example Additional OpenTelemetry resource attributes
OTEL_EXPORTER_JAEGER_AGENT_HOST localhost Jaeger host to use
OTEL_EXPORTER_JAEGER_AGENT_PORT 6831 Jaeger port to use (UDP)

Run server

$ OTEL_SERVICE_NAME=api OTEL_RESOURCE_ATTRIBUTES="service.namespace=example" go run ./cmd/api-server
{"level":"info","ts":1658763761.0027707,"caller":"api-server/main.go:27","msg":"Initializing","http.addr":"127.0.0.1:8080","metrics.addr":"127.0.0.1:9090"}
{"level":"info","ts":1658763761.0033038,"caller":"app/metrics.go:224","msg":"Metrics initialized","otel.resource":"service.name=api,service.namespace=example,telemetry.sdk.language=go,telemetry.sdk.name=opentelemetry,telemetry.sdk.version=1.8.0","http.addr":"127.0.0.1:9090"}

Check metrics

$ curl localhost:9090
Service is up and running.

Resource:
  service.name                     api
  service.namespace                example
  telemetry.sdk.language           go
  telemetry.sdk.name               opentelemetry
  telemetry.sdk.version            1.8.0

Available debug endpoints:
/metrics             - prometheus metrics
/debug/pprof         - exported pprof

Client

$ go run ./cmd/api-client --id 1337
pet: {
  "id": 1337,
  "name": "Pet 1337",
  "status": "available"
}

TODO

  • Add server context propagation example
  • Add client context propagation example

example's People

Contributors

ernado avatar tdakkota avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.