Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Split Inject and Extract Builtin interfaces #316

Merged
merged 1 commit into from
Jan 7, 2019

Conversation

tylerbenson
Copy link

If we had separate formats for inject and extract this refactor would have been much cleaner.

This allows us to better avoid partially implementing the TextMap interface and throwing an exception for the other method.

Since Binary is a new addition, I applied a similar refactoring to that.

Closes #315.

If we had separate formats for inject and extract this refactor would have been much cleaner.

This allows us to better avoid partially implementing the TextMap interface and throwing an exception for the other method.

Since Binary is a new addition, I applied a similar refactoring to that.

Closes opentracing#315.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.6%) to 76.0% when pulling 875022c on tylerbenson:tyler/text-map-split into b6f6324 on opentracing:v0.32.0.

@carlosalberto
Copy link
Collaborator

So I like this change definitely, but I'm wondering about breaking the API (which we could actually do for BINARY as we are breaking it anyway, and mostly because nobody uses it currently, AFAIK).

Wondering if there's something we could do to help with such API break.

* @see Format.Builtin#HTTP_HEADERS
*/
void put(String key, String value);
public interface TextMap extends TextMapInject, TextMapExtract {
Copy link
Member

Choose a reason for hiding this comment

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

are we deprecating this then?

Copy link
Author

Choose a reason for hiding this comment

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

I think it is still useful if someone wants to create a single wrapper for both inject/extract purposes. I don't think it's necessary to deprecate.

@tylerbenson
Copy link
Author

@carlosalberto what API breakage are you referring to that you'd like to avoid? I thought the way I made this change still maintained backwards compatibility.

I would still like to consider #305 which would definitely be a breaking change, but that isn't included in this yet.

@@ -13,6 +13,7 @@
*/
package io.opentracing.propagation;

import io.opentracing.SpanContext;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we really need it here? ;)

Copy link
Author

Choose a reason for hiding this comment

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

Since it's referenced in the javadoc and not fully qualified, it does need to be imported.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fair enough

@carlosalberto
Copy link
Collaborator

Hey @tylerbenson

Sorry for the late feedback, was busy with other things. So I think it indeed does not actually break the API, but I'm a little bit curious (more than concerned) with users having to change their injection code to:

tracer.inject(span.context(), Format.Builtin.TEXT_MAP_INJECT, carrier);

Or else have tracer authors check for both TEXT_MAP and TEXT_MAP_INJECT (and TEXT_MAP and TEXT_MAP_EXTRACT for the extraction scenario, etc). Probably this last one is the one making more sense, backwards-compatibility wise (interestingly enough, in MockTracer we wouldn't need to change the handling at all, as we don't check the Format<C> object, but only its C type ;) )

@tylerbenson
Copy link
Author

@carlosalberto I believe the way I wrote it allows the new built-in formats to be opt-in for API usage. For tracer authors, I think it depends on implementation, though I think using the type is probably the best option.

@carlosalberto
Copy link
Collaborator

Hey all,

I'd like to get this PR moving - specially as it will not break things (as @tylerbenson refactored things nicely).

One thing I still wonder is whether we should deprecate TextMap or keep it, as @tyler also mentioned:

I think it is still useful if someone wants to create a single wrapper for both inject/extract purposes

Thoughts? @opentracing/opentracing-java-maintainers

@tylerbenson
Copy link
Author

@carlosalberto We have a few additional approvals. I think this is ready for merge now.

@tylerbenson tylerbenson merged commit 639dd06 into opentracing:v0.32.0 Jan 7, 2019
@tylerbenson tylerbenson deleted the tyler/text-map-split branch January 7, 2019 19:47
carlosalberto added a commit that referenced this pull request Mar 25, 2019
* Deprecate the StringTag.set() overload taking a StringTag. (#262)
* Implement Trace Identifiers. (#280)
* Bump JaCoCo to use a Java 10 friendly version (#306)
* Remove finish span on close (#301)
  * Deprecate finishSpanOnClose on activation.
  * Add ScopeManager.activeSpan() and Tracer.activateSpan().
  * Clarify the API changes and deprecations.
  * Add an error reporting sample to opentracing-testbed.
* Simple layer on top of ByteBuffer for BINARY format. (#276)
* Add generic typed setTag/withTag (#311)
* Allow injecting into maps of type Map<String,Object> (#310)
* Add simple registerIfAbsent to global tracer (#289)
* Split Inject and Extract Builtin interfaces (#316)
* Deprecate ScopeManager.active() (#326)
* Make Tracer extends Closable. (#329)
* Do not make isRegistered() synchronized. (#333)
* Deprecate AutoFinishScopeManager (#335)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants