Skip to content
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

feat(otelgin): enhance gin error tracking with span recording #6346

Merged
merged 26 commits into from
Nov 27, 2024

Conversation

flc1125
Copy link
Member

@flc1125 flc1125 commented Nov 19, 2024

No description provided.

@flc1125 flc1125 requested a review from a team as a code owner November 19, 2024 16:10
@dmathieu
Copy link
Member

Could you test this change?
By checking there's indeed an error here for example: https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/instrumentation/github.com/gin-gonic/gin/otelgin/test/gintrace_test.go#L123

Also, I wonder if we need to keep the gin.errors attribute. While removing it is a breaking change, keeping it is redundant.

@dmathieu
Copy link
Member

Side note that otelgin has no owner, so it may be removed soon.
#6190

@flc1125
Copy link
Member Author

flc1125 commented Nov 20, 2024

Side note that otelgin has no owner, so it may be removed soon. #6190

Okay, will this package still accept new PRs at present?

@dmathieu
Copy link
Member

It does.

Copy link

codecov bot commented Nov 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.9%. Comparing base (9bbebd9) to head (59de17e).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #6346   +/-   ##
=====================================
  Coverage   66.9%   66.9%           
=====================================
  Files        193     193           
  Lines      15652   15654    +2     
=====================================
+ Hits       10480   10482    +2     
  Misses      4881    4881           
  Partials     291     291           
Files with missing lines Coverage Δ
...ation/github.com/gin-gonic/gin/otelgin/gintrace.go 84.3% <100.0%> (+0.3%) ⬆️

@flc1125
Copy link
Member Author

flc1125 commented Nov 20, 2024

#6190

I think I can give it a try.

If I come to maintain it, what do I need to do?

@dmathieu
Copy link
Member

That's documented in the issue, as well as in https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/CONTRIBUTING.md#code-owners.

CHANGELOG.md Outdated Show resolved Hide resolved
@flc1125
Copy link
Member Author

flc1125 commented Nov 21, 2024

Could you test this change? By checking there's indeed an error here for example: main/instrumentation/github.com/gin-gonic/gin/otelgin/test/gintrace_test.go#L123

Also, I wonder if we need to keep the gin.errors attribute. While removing it is a breaking change, keeping it is redundant.

It's done.

@flc1125
Copy link
Member Author

flc1125 commented Nov 21, 2024

Side note that otelgin has no owner, so it may be removed soon.

I spent some time reading through the requirements. I understand that I may still need to make some contributions before applying. If so, I need some time.

.golangci.yml Outdated Show resolved Hide resolved
@flc1125
Copy link
Member Author

flc1125 commented Nov 21, 2024

link: #5252

@dmathieu dmathieu dismissed their stale review November 21, 2024 13:23

Changes made

@flc1125 flc1125 requested a review from dmathieu November 21, 2024 14:14
Copy link
Member

@dmathieu dmathieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is starting to look good 😸

@flc1125 flc1125 requested a review from dmathieu November 21, 2024 15:13
@dmathieu
Copy link
Member

Could you resolve the conflicts?

…ace-recorderror

# Conflicts:
#	instrumentation/github.com/gin-gonic/gin/otelgin/gintrace_test.go
#	instrumentation/github.com/gin-gonic/gin/otelgin/test/gintrace_test.go
@github-actions github-actions bot requested a review from akats7 November 25, 2024 15:24
@flc1125
Copy link
Member Author

flc1125 commented Nov 25, 2024

Could you resolve the conflicts?

It's done.

@dmathieu dmathieu removed the request for review from akats7 November 25, 2024 15:28
@akats7
Copy link
Contributor

akats7 commented Nov 25, 2024

@dmathieu I could pick up ownership of this module so that it isn't removed, should I just open a PR on the codeowners file?

@dmathieu
Copy link
Member

Yes, that should be enough (link the otelgin deprecation issue in that PR).

@pellared
Copy link
Member

@dmathieu I could pick up ownership of this module so that it isn't removed, should I just open a PR on the codeowners file?

Could you review this PR if you want to be an code owner? 😉

@MrAlias
Copy link
Contributor

MrAlias commented Nov 25, 2024

@dmathieu I could pick up ownership of this module so that it isn't removed, should I just open a PR on the codeowners file?

Could you review this PR if you want to be an code owner? 😉

cc @akats7 (I think)

@akats7
Copy link
Contributor

akats7 commented Nov 25, 2024

lgtm, my only real thought is I personally always find it convenient to have the error message at least partially included directly on the span instead of only having the span events. Since span events are sometimes (always?) stored in separate table it could becomes an additional step to view the message depending on the platform you use.

For example I know a lot of the java instrumentation just adds error: true as an attribute and then creates a span event, and we've had teams complain that the error message has no contextual info

@flc1125
Copy link
Member Author

flc1125 commented Nov 26, 2024

lgtm, my only real thought is I personally always find it convenient to have the error message at least partially included directly on the span instead of only having the span events. Since span events are sometimes (always?) stored in separate table it could becomes an additional step to view the message depending on the platform you use.

For example I know a lot of the java instrumentation just adds error: true as an attribute and then creates a span event, and we've had teams complain that the error message has no contextual info

This is indeed a problem, and it usually depends on what backend tools we are using.

Fortunately, when the entire span contains some abnormal events, the tool I am currently using allows me to see the exception information directly in the span interface. Of course, for more detailed information, I still need to switch to view it in Events.

——

Back to this PR, due to the OTEL standard specifications, I suggest we still maintain storing exceptions in Events. After all, this project is for the majority of users, and we need to present ourselves as professionally as possible and in accordance with the standards. 😁

@akats7
Copy link
Contributor

akats7 commented Nov 26, 2024

Yes we need to record the errors as a span event, what I'm getting at is when it comes to:

	span.SetAttributes(attribute.String("gin.errors", c.Errors.String()))

or

	span.SetStatus(codes.Error, "gin error")

I do find including the error string to have value

@pellared pellared requested a review from MrAlias November 26, 2024 17:37
@pellared pellared merged commit dfd6b16 into open-telemetry:main Nov 27, 2024
26 checks passed
@flc1125 flc1125 deleted the gintrace-recorderror branch November 27, 2024 11:26
@MrAlias MrAlias added this to the v1.33.0 milestone Dec 11, 2024
MrAlias added a commit that referenced this pull request Dec 12, 2024
### Added

- Added support for providing `endpoint`, `pollingIntervalMs` and
`initialSamplingRate` using environment variable
`OTEL_TRACES_SAMPLER_ARG` in
`go.opentelemetry.io/contrib/samples/jaegerremote`. (#6310)
- Added support exporting logs via OTLP over gRPC in
`go.opentelemetry.io/contrib/config`. (#6340)
- The `go.opentelemetry.io/contrib/bridges/otellogr` module.
This module provides an OpenTelemetry logging bridge for
`github.com/go-logr/logr`. (#6386)
- Added SNS instrumentation in
`go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws`.
(#6388)

### Changed

- Change the span name to be `GET /path` so it complies with the OTel
HTTP semantic conventions in
`go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho`.
(#6365)
- Record errors instead of setting the `gin.errors` attribute in
`go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin`.
(#6346)
- The `go.opentelemetry.io/contrib/config` now supports multiple schemas
in subdirectories (i.e. `go.opentelemetry.io/contrib/config/v0.3.0`) for
easier migration. (#6412)

### Fixed

- Fix broken AWS presigned URLs when using instrumentation in
`go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws`.
(#5975)
- Fixed the value for configuring the OTLP exporter to use `grpc`
instead of `grpc/protobuf` in `go.opentelemetry.io/contrib/config`.
(#6338)
- Allow marshaling types in `go.opentelemetry.io/contrib/config`.
(#6347)
- Removed the redundant handling of panic from the `HTML` function in
`go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin`.
(#6373)
- The `code.function` attribute emitted by
`go.opentelemetry.io/contrib/bridges/otelslog` now stores just the
function name instead the package path-qualified function name. The
`code.namespace` attribute now stores the package path. (#6415)
- The `code.function` attribute emitted by
`go.opentelemetry.io/contrib/bridges/otelzap` now stores just the
function name instead the package path-qualified function name. The
`code.namespace` attribute now stores the package path. (#6423)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants