@@ -204,6 +204,9 @@ static <T extends Context> Observation createNotStarted(String name, Supplier<T>
204
204
return NOOP ;
205
205
}
206
206
Context context = contextSupplier .get ();
207
+ if (context .getName () == null ) {
208
+ context .setName (name );
209
+ }
207
210
context .setParentFromCurrentObservation (registry );
208
211
context .setLevel (level != null ? level : null );
209
212
if (!registry .observationConfig ().isObservationEnabled (name , context )) {
@@ -1596,91 +1599,76 @@ class ObservationLevel {
1596
1599
1597
1600
private final Level level ;
1598
1601
1599
- private final Class <?> clazz ;
1600
-
1601
- public ObservationLevel (Level level , Class <?> clazz ) {
1602
+ public ObservationLevel (Level level ) {
1602
1603
this .level = level ;
1603
- this .clazz = clazz ;
1604
1604
}
1605
1605
1606
1606
public Level getLevel () {
1607
1607
return level ;
1608
1608
}
1609
1609
1610
- public Class <?> getClazz () {
1611
- return clazz ;
1612
- }
1613
-
1614
1610
/**
1615
1611
* Sets {@link Level#ALL} for observation of the given classs.
1616
- * @param clazz class to observe
1617
1612
* @return observation level
1618
1613
*/
1619
- public static ObservationLevel all (Class <?> clazz ) {
1620
- return new ObservationLevel (Level .ALL , clazz );
1614
+ public static ObservationLevel all () {
1615
+ return new ObservationLevel (Level .ALL );
1621
1616
}
1622
1617
1623
1618
/**
1624
1619
* Sets {@link Level#TRACE} for observation of the given classs.
1625
- * @param clazz class to observe
1626
1620
* @return observation level
1627
1621
*/
1628
- public static ObservationLevel trace (Class <?> clazz ) {
1629
- return new ObservationLevel (Level .TRACE , clazz );
1622
+ public static ObservationLevel trace () {
1623
+ return new ObservationLevel (Level .TRACE );
1630
1624
}
1631
1625
1632
1626
/**
1633
1627
* Sets {@link Level#DEBUG} for observation of the given classs.
1634
- * @param clazz class to observe
1635
1628
* @return observation level
1636
1629
*/
1637
- public static ObservationLevel debug (Class <?> clazz ) {
1638
- return new ObservationLevel (Level .DEBUG , clazz );
1630
+ public static ObservationLevel debug () {
1631
+ return new ObservationLevel (Level .DEBUG );
1639
1632
}
1640
1633
1641
1634
/**
1642
1635
* Sets {@link Level#INFO} for observation of the given classs.
1643
- * @param clazz class to observe
1644
1636
* @return observation level
1645
1637
*/
1646
- public static ObservationLevel info (Class <?> clazz ) {
1647
- return new ObservationLevel (Level .INFO , clazz );
1638
+ public static ObservationLevel info () {
1639
+ return new ObservationLevel (Level .INFO );
1648
1640
}
1649
1641
1650
1642
/**
1651
1643
* Sets {@link Level#WARN} for observation of the given classs.
1652
- * @param clazz class to observe
1653
1644
* @return observation level
1654
1645
*/
1655
- public static ObservationLevel warn (Class <?> clazz ) {
1656
- return new ObservationLevel (Level .WARN , clazz );
1646
+ public static ObservationLevel warn () {
1647
+ return new ObservationLevel (Level .WARN );
1657
1648
}
1658
1649
1659
1650
/**
1660
1651
* Sets {@link Level#ERROR} for observation of the given classs.
1661
- * @param clazz class to observe
1662
1652
* @return observation level
1663
1653
*/
1664
- public static ObservationLevel error (Class <?> clazz ) {
1665
- return new ObservationLevel (Level .ERROR , clazz );
1654
+ public static ObservationLevel error () {
1655
+ return new ObservationLevel (Level .ERROR );
1666
1656
}
1667
1657
1668
1658
/**
1669
1659
* Sets {@link Level#FATAL} for observation of the given classs.
1670
- * @param clazz class to observe
1671
1660
* @return observation level
1672
1661
*/
1673
- public static ObservationLevel fatal (Class <?> clazz ) {
1674
- return new ObservationLevel (Level .FATAL , clazz );
1662
+ public static ObservationLevel fatal () {
1663
+ return new ObservationLevel (Level .FATAL );
1675
1664
}
1676
1665
1677
1666
/**
1678
1667
* Sets {@link Level#OFF} for observation of the given classs.
1679
- * @param clazz class to observe
1680
1668
* @return observation level
1681
1669
*/
1682
- public static ObservationLevel off (Class <?> clazz ) {
1683
- return new ObservationLevel (Level .OFF , clazz );
1670
+ public static ObservationLevel off () {
1671
+ return new ObservationLevel (Level .OFF );
1684
1672
}
1685
1673
1686
1674
}
0 commit comments