@@ -43,6 +43,7 @@ void testPrintInstrumentationList() throws Exception {
4343 "Spring Web 6.0 instrumentation" ,
4444 InstrumentationClassification .LIBRARY .toString (),
4545 true ,
46+ null ,
4647 null );
4748
4849 modules .add (
@@ -114,6 +115,7 @@ void testGenerateInstrumentationYamlSeparatesClassifications() throws Exception
114115 "Spring Web 6.0 instrumentation" ,
115116 InstrumentationClassification .LIBRARY .toString (),
116117 false ,
118+ null ,
117119 List .of (
118120 new ConfigurationOption (
119121 "otel.instrumentation.spring-web-6.0.enabled" ,
@@ -134,7 +136,7 @@ void testGenerateInstrumentationYamlSeparatesClassifications() throws Exception
134136
135137 InstrumentationMetaData internalMetadata =
136138 new InstrumentationMetaData (
137- null , InstrumentationClassification .INTERNAL .toString (), null , null );
139+ null , InstrumentationClassification .INTERNAL .toString (), null , null , null );
138140
139141 modules .add (
140142 new InstrumentationModule .Builder ()
@@ -148,7 +150,7 @@ void testGenerateInstrumentationYamlSeparatesClassifications() throws Exception
148150
149151 InstrumentationMetaData customMetadata =
150152 new InstrumentationMetaData (
151- null , InstrumentationClassification .CUSTOM .toString (), null , null );
153+ null , InstrumentationClassification .CUSTOM .toString (), null , null , null );
152154
153155 Map <InstrumentationType , Set <String >> externalAnnotationsVersions =
154156 Map .of (
@@ -214,6 +216,7 @@ void testMetadataParser() throws JsonProcessingException {
214216 description: test description
215217 classification: internal
216218 disabled_by_default: true
219+ library_link: https://example.com/test-library
217220 configurations:
218221 - name: otel.instrumentation.common.db-statement-sanitizer.enabled
219222 description: Enables statement sanitization for database queries.
@@ -233,6 +236,7 @@ void testMetadataParser() throws JsonProcessingException {
233236 assertThat (metadata .getClassification ()).isEqualTo (InstrumentationClassification .INTERNAL );
234237 assertThat (metadata .getDescription ()).isEqualTo ("test description" );
235238 assertThat (metadata .getDisabledByDefault ()).isEqualTo (true );
239+ assertThat (metadata .getLibraryLink ()).isEqualTo ("https://example.com/test-library" );
236240 }
237241
238242 @ Test
@@ -241,6 +245,18 @@ void testMetadataParserWithOnlyLibraryEntry() throws JsonProcessingException {
241245 InstrumentationMetaData metadata = YamlHelper .metaDataParser (input );
242246 assertThat (metadata .getClassification ()).isEqualTo (InstrumentationClassification .INTERNAL );
243247 assertThat (metadata .getDescription ()).isNull ();
248+ assertThat (metadata .getLibraryLink ()).isNull ();
249+ assertThat (metadata .getDisabledByDefault ()).isFalse ();
250+ assertThat (metadata .getConfigurations ()).isEmpty ();
251+ }
252+
253+ @ Test
254+ void testMetadataParserWithOnlyLibraryLink () throws JsonProcessingException {
255+ String input = "library_link: https://example.com/only-link" ;
256+ InstrumentationMetaData metadata = YamlHelper .metaDataParser (input );
257+ assertThat (metadata .getClassification ()).isEqualTo (InstrumentationClassification .LIBRARY );
258+ assertThat (metadata .getDescription ()).isNull ();
259+ assertThat (metadata .getLibraryLink ()).isEqualTo ("https://example.com/only-link" );
244260 assertThat (metadata .getDisabledByDefault ()).isFalse ();
245261 assertThat (metadata .getConfigurations ()).isEmpty ();
246262 }
@@ -485,4 +501,80 @@ void testTelemetryGroupsAreSorted() throws Exception {
485501
486502 assertThat (yaml1 ).isEqualTo (yaml2 );
487503 }
504+
505+ @ Test
506+ void testYamlGenerationWithLibraryLink () throws Exception {
507+ List <InstrumentationModule > modules = new ArrayList <>();
508+ Map <InstrumentationType , Set <String >> targetVersions = new HashMap <>();
509+ targetVersions .put (
510+ InstrumentationType .JAVAAGENT , new HashSet <>(List .of ("com.example:test-library:[1.0.0,)" )));
511+
512+ InstrumentationMetaData metadataWithLink =
513+ new InstrumentationMetaData (
514+ "Test library instrumentation with link" ,
515+ InstrumentationClassification .LIBRARY .toString (),
516+ false ,
517+ "https://example.com/test-library-docs" ,
518+ emptyList ());
519+
520+ modules .add (
521+ new InstrumentationModule .Builder ()
522+ .srcPath ("instrumentation/test-lib/test-lib-1.0" )
523+ .instrumentationName ("test-lib-1.0" )
524+ .namespace ("test-lib" )
525+ .group ("test-lib" )
526+ .targetVersions (targetVersions )
527+ .metadata (metadataWithLink )
528+ .build ());
529+
530+ InstrumentationMetaData metadataWithoutLink =
531+ new InstrumentationMetaData (
532+ "Test library instrumentation without link" ,
533+ InstrumentationClassification .LIBRARY .toString (),
534+ false ,
535+ null ,
536+ emptyList ());
537+
538+ modules .add (
539+ new InstrumentationModule .Builder ()
540+ .srcPath ("instrumentation/other-lib/other-lib-1.0" )
541+ .instrumentationName ("other-lib-1.0" )
542+ .namespace ("other-lib" )
543+ .group ("other-lib" )
544+ .targetVersions (targetVersions )
545+ .metadata (metadataWithoutLink )
546+ .build ());
547+
548+ StringWriter stringWriter = new StringWriter ();
549+ BufferedWriter writer = new BufferedWriter (stringWriter );
550+
551+ YamlHelper .generateInstrumentationYaml (modules , writer );
552+ writer .flush ();
553+
554+ String expectedYaml =
555+ """
556+ libraries:
557+ other-lib:
558+ - name: other-lib-1.0
559+ description: Test library instrumentation without link
560+ source_path: instrumentation/other-lib/other-lib-1.0
561+ scope:
562+ name: io.opentelemetry.other-lib-1.0
563+ target_versions:
564+ javaagent:
565+ - com.example:test-library:[1.0.0,)
566+ test-lib:
567+ - name: test-lib-1.0
568+ description: Test library instrumentation with link
569+ library_link: https://example.com/test-library-docs
570+ source_path: instrumentation/test-lib/test-lib-1.0
571+ scope:
572+ name: io.opentelemetry.test-lib-1.0
573+ target_versions:
574+ javaagent:
575+ - com.example:test-library:[1.0.0,)
576+ """ ;
577+
578+ assertThat (expectedYaml ).isEqualTo (stringWriter .toString ());
579+ }
488580}
0 commit comments