-
Notifications
You must be signed in to change notification settings - Fork 109
feat: [#726] Add HTTP server and client telemetry instrumentation [5] #1326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 17 commits
2c9466a
7ccca56
8df0782
01ecf4b
0d8fda5
b2c07d5
395f109
bb1f529
441ba96
cb3cb89
7c59c97
ab72e2a
413bdd6
f999029
98ec1f7
ad59c56
1fea34b
794ed71
76021c2
eb97e1b
c23884a
e4faad6
5141d18
5a26971
5a5d9fc
75130b9
09f4745
9793141
bd0645b
f7e34b8
777ce25
43a7d8f
9d3460c
4fcd103
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -156,7 +156,7 @@ func getHandlers(config config.Config, json foundation.Json, channel string) ([] | |
| handlers = append(handlers, HandlerToSlogHandler(logger.NewConsoleHandler(config, json, level, formatter))) | ||
| } | ||
| case log.DriverOtel: | ||
| logLogger := telemetrylog.NewTelemetryChannel() | ||
| logLogger := telemetrylog.NewTelemetryChannel(config) | ||
|
||
| handler, err := logLogger.Handle(channelPath) | ||
| if err != nil { | ||
| return nil, err | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| package http | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "go.opentelemetry.io/otel/attribute" | ||
|
|
||
| "github.com/goravel/framework/contracts/http" | ||
| ) | ||
|
|
||
| // Filter allows excluding specific requests from being traced. | ||
| type Filter func(ctx http.Context) bool | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated the annotation |
||
|
|
||
| // SpanNameFormatter allows customizing the span name. | ||
| type SpanNameFormatter func(route string, ctx http.Context) string | ||
|
|
||
| // Option applies configuration to the server instrumentation. | ||
| type Option func(*ServerConfig) | ||
|
|
||
| // ServerConfig maps to "telemetry.instrumentation.http_server". | ||
| type ServerConfig struct { | ||
| Enabled bool `mapstructure:"enabled"` | ||
krishankumar01 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ExcludedPaths []string `mapstructure:"excluded_paths"` | ||
| ExcludedMethods []string `mapstructure:"excluded_methods"` | ||
| Filters []Filter `mapstructure:"-"` | ||
| SpanNameFormatter SpanNameFormatter `mapstructure:"-"` | ||
| MetricAttributes []attribute.KeyValue `mapstructure:"-"` | ||
| } | ||
|
|
||
| func WithFilter(f Filter) Option { | ||
| return func(c *ServerConfig) { | ||
| c.Filters = append(c.Filters, f) | ||
| } | ||
| } | ||
|
|
||
| func WithSpanNameFormatter(f SpanNameFormatter) Option { | ||
| return func(c *ServerConfig) { | ||
| c.SpanNameFormatter = f | ||
| } | ||
| } | ||
|
|
||
| func WithMetricAttributes(attrs ...attribute.KeyValue) Option { | ||
| return func(c *ServerConfig) { | ||
| c.MetricAttributes = append(c.MetricAttributes, attrs...) | ||
| } | ||
| } | ||
|
|
||
| func defaultSpanNameFormatter(route string, ctx http.Context) string { | ||
| return fmt.Sprintf("%s %s", ctx.Request().Method(), route) | ||
| } | ||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving the route registration to the end, because if a user registers any gRPC stats handler or interceptors after calling
routes.Grpc()(since in this file we usually callfacades.Grpc().Server()), they will be ignored as the server is initialized only once ingrpc/application.go.