-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Micrometer Observation support to Spring Dapr Messaging (#1150)
* Add Micrometer Observation support to Spring Dapr Messaging Signed-off-by: Artur Ciocanu <[email protected]> * Remove direct Micrometer deps it is part of Spring Boot Signed-off-by: Artur Ciocanu <[email protected]> * Remove another explicit dependency Signed-off-by: Artur Ciocanu <[email protected]> * Hide default observation convention implementation Signed-off-by: Artur Ciocanu <[email protected]> * Fix typo in default message builder Signed-off-by: Artur Ciocanu <[email protected]> * Ensure trace is properly sent using OTEL Signed-off-by: Artur Ciocanu <[email protected]> --------- Signed-off-by: Artur Ciocanu <[email protected]> Co-authored-by: Artur Ciocanu <[email protected]>
- Loading branch information
1 parent
0b7a051
commit be05a47
Showing
11 changed files
with
448 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...rc/main/java/io/dapr/spring/messaging/observation/DaprMessagingObservationConvention.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2024 The Dapr Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.dapr.spring.messaging.observation; | ||
|
||
import io.micrometer.observation.Observation.Context; | ||
import io.micrometer.observation.ObservationConvention; | ||
|
||
/** | ||
* {@link ObservationConvention} for Dapr Messaging. | ||
* | ||
*/ | ||
public interface DaprMessagingObservationConvention extends ObservationConvention<DaprMessagingSenderContext> { | ||
|
||
@Override | ||
default boolean supportsContext(Context context) { | ||
return context instanceof DaprMessagingSenderContext; | ||
} | ||
|
||
@Override | ||
default String getName() { | ||
return "spring.dapr.messaging.template"; | ||
} | ||
|
||
static DaprMessagingObservationConvention getDefault() { | ||
return DefaultDaprMessagingObservationConvention.INSTANCE; | ||
} | ||
|
||
} |
64 changes: 64 additions & 0 deletions
64
...main/java/io/dapr/spring/messaging/observation/DaprMessagingObservationDocumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2024 The Dapr Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.dapr.spring.messaging.observation; | ||
|
||
import io.micrometer.common.docs.KeyName; | ||
import io.micrometer.observation.Observation; | ||
import io.micrometer.observation.Observation.Context; | ||
import io.micrometer.observation.ObservationConvention; | ||
import io.micrometer.observation.docs.ObservationDocumentation; | ||
|
||
/** | ||
* An {@link Observation} for {@link io.dapr.spring.messaging.DaprMessagingTemplate}. | ||
* | ||
*/ | ||
public enum DaprMessagingObservationDocumentation implements ObservationDocumentation { | ||
|
||
/** | ||
* Observation created when a Dapr template sends a message. | ||
*/ | ||
TEMPLATE_OBSERVATION { | ||
|
||
@Override | ||
public Class<? extends ObservationConvention<? extends Context>> getDefaultConvention() { | ||
return DefaultDaprMessagingObservationConvention.class; | ||
} | ||
|
||
@Override | ||
public String getPrefix() { | ||
return "spring.dapr.messaging.template"; | ||
} | ||
|
||
@Override | ||
public KeyName[] getLowCardinalityKeyNames() { | ||
return TemplateLowCardinalityTags.values(); | ||
} | ||
}; | ||
|
||
/** | ||
* Low cardinality tags. | ||
*/ | ||
public enum TemplateLowCardinalityTags implements KeyName { | ||
/** | ||
* Bean name of the template that sent the message. | ||
*/ | ||
BEAN_NAME { | ||
|
||
@Override | ||
public String asString() { | ||
return "spring.dapr.messaging.template.name"; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.