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

Abstraction for metrics and tracing #634

Merged

Conversation

slinkydeveloper
Copy link
Member

@slinkydeveloper slinkydeveloper commented Dec 2, 2020

The goal of this PR is to introduce an abstraction to remove from the core sdk module the dependencies over metrics and tracing. Part of #619

Content of this PR:

  • the core module doesn't depend anymore on opencensus
  • the core module provides an abstraction to plug tracing and metrics in send/receive/request, called ObservabilityService
  • there is a new separate module that provides the same support as before for opencensus + extras
  • Observability is now used only in Client and not anymore in marshalling/unmarshalling hot paths
  • Fixed some wrong context propagation with http using the client receiver

Breaking changes:

Users of metrics and tracing will have to modify their code to support this change. Now they won't need to use client.NewObservable and http.NewObservable, but they'll must use the observability service and the http protocol factory from the opencensus package

Deprecated (and short-circuited functions):

  • client.NewObservable (now it's like client.New)
  • http.NewObservable (now it's like http.New)

Removed functions:

Signed-off-by: Francesco Guardiani francescoguard@gmail.com

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
@slinkydeveloper slinkydeveloper changed the title [WIP] abstraction for metrics and tracing Abstraction for metrics and tracing Jan 7, 2021
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
@@ -9,7 +9,7 @@ import (
)

func NewHTTPReceiveHandler(ctx context.Context, p *thttp.Protocol, fn interface{}) (*EventReceiver, error) {
invoker, err := newReceiveInvoker(fn)
invoker, err := newReceiveInvoker(fn, noopObservabilityService{})
Copy link
Member

Choose a reason for hiding this comment

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

We should get ahead of this and add a observability.Get() that defaults to noopObservabilityService here and everywhere else. We can do this as a follow up but it should happen before we cut

Copy link
Member Author

@slinkydeveloper slinkydeveloper Jan 7, 2021

Choose a reason for hiding this comment

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

sure, let's stabilize in a followup. There is some code in opencensus that can be eventually get removed too

// Protocol client. The http transport has had WithBinaryEncoding http
// transport option applied to it. The client will always send Binary
// encoding but will inspect the outbound event context and match the version.
// Protocol client.
// The WithTimeNow, and WithUUIDs client options are also applied to the
// client, all outbound events will have a time and id set if not already
// present.
func NewDefault(opts ...http.Option) (Client, error) {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should deprecate this method and comment how to get the same result with client.NewHTTP and then alias that to cloudevents.NewHTTPClient

Fixed integration test

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
@n3wscott
Copy link
Member

n3wscott commented Jan 7, 2021

LGTM
APPROVE

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.

2 participants