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

SetContext is under documented #427

Closed
rkuska opened this issue Mar 31, 2022 · 1 comment
Closed

SetContext is under documented #427

rkuska opened this issue Mar 31, 2022 · 1 comment

Comments

@rkuska
Copy link

rkuska commented Mar 31, 2022

Summary

SetContext function signature can be improved to make it clear to users that it only accept maps. Unless it is not a case and there is a bug to be fixed.

I searched the repository for usage but it seems the same (the tests are using the same approach as mine above). In online documentation there is a following statement:

The best practice to attach custom data is via structured contexts. A context must always be a dictionary or map, and its values can be arbitrary.

Why the function doesn't have in its signature that it accepts only map[string]interface{} but instead there is interface{}? Current signature seems counter-intuitive.

Also, is there a way to enrich the context under a given key later? Right now the object under the key is being overwritten so the namespace can't be enriched.

Steps To Reproduce

hub := sentry.CurrentHub().Clone()
hub.ConfigureScope(func(scope *sentry.Scope) {
	scope.SetContext("tx_type", batch.ttype)
	scope.SetContext("strategy", batch.strategy)
})
_ = hub.CaptureMessage("Message")

Expected Behavior

Values to be rendered correctly.

Screenshots

Screenshot 2022-03-31 at 16 44 18

Environment

SDK

  • sentry-go version: github.com/getsentry/sentry-go v0.12.0
  • Go version: 1.16
  • Using Go Modules? yes

Sentry

  • Using hosted Sentry in sentry.io? Yes
  • Using your own Sentry installation? Version:
  • Anything particular to your environment that could be related to this issue?

Additional context

@cleptric
Copy link
Member

Fixed in v0.14.0 via #444

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants