• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ExpediaGroup / beekeeper / #811

06 Apr 2026 07:31PM UTC coverage: 87.706% (-0.07%) from 87.774%
#811

push

web-flow
Merge 6da37a9c7 into 2a21fe15a

10 of 12 new or added lines in 3 files covered. (83.33%)

115 existing lines in 33 files now uncovered.

1541 of 1757 relevant lines covered (87.71%)

0.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/beekeeper-core/src/main/java/com/expediagroup/beekeeper/core/monitoring/TimedTaggableAspect.java
1
/**
2
 * Copyright (C) 2017-2019 Expedia, Inc and Pivotal Software, Inc.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15

16
 * This class is loosely based on {@link io.micrometer.core.aop.TimedAspect}. It has been adapted in order to create
17
 * a custom tag for the timer metric that is registered each time it is called.
18
 */
19
package com.expediagroup.beekeeper.core.monitoring;
20

21
import org.apache.commons.lang3.StringUtils;
22
import org.aspectj.lang.ProceedingJoinPoint;
23
import org.aspectj.lang.annotation.Around;
24
import org.aspectj.lang.annotation.Aspect;
25
import org.springframework.beans.factory.annotation.Autowired;
26
import org.springframework.stereotype.Component;
27

28
import io.micrometer.core.instrument.MeterRegistry;
29
import io.micrometer.core.instrument.Tags;
30
import io.micrometer.core.instrument.Timer;
31

32
/**
33
 * Aspect for intercepting methods annotated with {@link TimedTaggable}.
34
 *
35
 * The method can have any number of arguments but a {@link Taggable} must be the first. Will add the custom tag to the
36
 * timer metric.
37
 */
38
@Aspect
39
@Component
40
public class TimedTaggableAspect {
41

42
  public static final String EXCEPTION_TAG = "exception";
43

44
  private MeterRegistry meterRegistry;
45

1✔
46
  @Autowired
1✔
47
  public TimedTaggableAspect(MeterRegistry meterRegistry) {
1✔
48
    this.meterRegistry = meterRegistry;
49
  }
50

51
  @Around("@annotation(timedTaggable) && args(taggable,..)")
52
  public Object time(
1✔
53
      ProceedingJoinPoint pjp,
1✔
54
      Taggable taggable,
1✔
55
      TimedTaggable timedTaggable)
56
    throws Throwable {
1✔
UNCOV
57
    String metricName = timedTaggable.value();
×
UNCOV
58
    Timer.Sample sample = Timer.start(meterRegistry);
×
UNCOV
59
    String exceptionClass = "none";
×
60
    try {
61
      return pjp.proceed();
62
    } catch (Exception ex) {
1✔
63
      exceptionClass = ex.getClass().getSimpleName();
1✔
64
      throw ex;
1✔
65
    } finally {
1✔
66
      try {
1✔
UNCOV
67
        sample.stop(Timer.builder(metricName)
×
68
          .tags(EXCEPTION_TAG, exceptionClass)
69
          .tags(metricTags(pjp, taggable.getMetricTag()))
1✔
70
          .register(meterRegistry));
71
      } catch (Exception e) {
72
        // ignoring on purpose
73
      }
74
    }
1✔
75
  }
1✔
76

77
  private Tags metricTags(ProceedingJoinPoint pjp, MetricTag metricTag) {
1✔
78
    Tags tags = Tags.of("class", pjp.getStaticPart().getSignature().getDeclaringTypeName(),
79
      "method", pjp.getStaticPart().getSignature().getName());
1✔
80
    if (!StringUtils.isBlank(metricTag.getTag()) && !StringUtils.isBlank(metricTag.getKey())) {
1✔
81
      tags = tags.and(metricTag.getKey(), metricTag.getTag());
1✔
82
    }
83
    return tags;
1✔
84
  }
85

86
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc