Skip to content

Commit

Permalink
Allow documenting optional keys (#3454)
Browse files Browse the repository at this point in the history
There is no distinction between required and optional keys currently when using ObservationDocumentation. This introduces a new method `isRequired` that will default to true. Optional keys may be documented by overriding this method.

Future use of this can be in the docs-generator marking whether a key is required or not in the generated documentation.
Also, testing the instrumentation with our TCKs can check that required keys are always present, and that undocumented keys are not present but optional keys may or may not be present.
  • Loading branch information
shakuzen committed Oct 5, 2022
1 parent e2b660e commit b732f2e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Expand Up @@ -62,4 +62,13 @@ default KeyValue withValue(String value, Predicate<Object> validator) {
*/
String asString();

/**
* Whether this key is required to be present in the instrumentation. This can be
* checked in a test of the instrumentation.
* @return whether this key is required
*/
default boolean isRequired() {
return true;
}

}
Expand Up @@ -356,6 +356,19 @@ enum MyKeyName implements KeyName {
public String asString() {
return "foo";
}
},

MAYBE_SOMETHING {

@Override
public String asString() {
return "maybe.something";
}

@Override
public boolean isRequired() {
return false;
}
}

}
Expand Down

0 comments on commit b732f2e

Please sign in to comment.