@@ -1333,7 +1333,6 @@ function Rollbar(options, client) {
1333
1333
this . options . _configuredOptions = options ;
1334
1334
var api = new API ( this . options , transport , urllib ) ;
1335
1335
this . client = client || new Client ( this . options , api , logger , 'browser' ) ;
1336
-
1337
1336
var gWindow = _gWindow ( ) ;
1338
1337
var gDocument = ( typeof document != 'undefined' ) && document ;
1339
1338
this . isChrome = gWindow . chrome && gWindow . chrome . runtime ; // check .runtime to avoid Edge browsers
@@ -1841,7 +1840,7 @@ function _gWindow() {
1841
1840
/* global __DEFAULT_ENDPOINT__:false */
1842
1841
1843
1842
var defaultOptions = {
1844
- version : "2.16.2 " ,
1843
+ version : "2.17.0 " ,
1845
1844
scrubFields : [ "pw" , "pass" , "passwd" , "password" , "secret" , "confirm_password" , "confirmPassword" , "password_confirmation" , "passwordConfirmation" , "access_token" , "accessToken" , "X-Rollbar-Access-Token" , "secret_key" , "secretKey" , "secretToken" , "cc-number" , "card number" , "cardnumber" , "cardnum" , "ccnum" , "ccnumber" , "cc num" , "creditcardnumber" , "credit card number" , "newcreditcardnumber" , "new credit card" , "creditcardno" , "credit card no" , "card#" , "card #" , "cc-csc" , "cvc" , "cvc2" , "cvv2" , "ccv2" , "security code" , "card verification" , "name on credit card" , "name on card" , "nameoncard" , "cardholder" , "card holder" , "name des karteninhabers" , "ccname" , "card type" , "cardtype" , "cc type" , "cctype" , "payment type" , "expiration date" , "expirationdate" , "expdate" , "cc-exp" , "ccmonth" , "ccyear" ] ,
1846
1845
logLevel : "debug" ,
1847
1846
reportLevel : "debug" ,
@@ -1888,6 +1887,18 @@ function Rollbar(options, api, logger, platform) {
1888
1887
Rollbar . rateLimiter . setPlatformOptions ( platform , this . options ) ;
1889
1888
this . api = api ;
1890
1889
this . queue = new Queue ( Rollbar . rateLimiter , api , logger , this . options ) ;
1890
+
1891
+ // This must happen before the Notifier is created
1892
+ var tracer = this . options . tracer || null ;
1893
+ if ( validateTracer ( tracer ) ) {
1894
+ this . tracer = tracer ;
1895
+ // set to a string for api response serialization
1896
+ this . options . tracer = 'opentracing-tracer-enabled' ;
1897
+ this . options . _configuredOptions . tracer = 'opentracing-tracer-enabled' ;
1898
+ } else {
1899
+ this . tracer = null ;
1900
+ }
1901
+
1891
1902
this . notifier = new Notifier ( this . queue , this . options ) ;
1892
1903
this . telemeter = new Telemeter ( this . options ) ;
1893
1904
setStackTraceLimit ( options ) ;
@@ -1902,81 +1913,99 @@ var defaultOptions = {
1902
1913
1903
1914
Rollbar . rateLimiter = new RateLimiter ( defaultOptions ) ;
1904
1915
1905
- Rollbar . prototype . global = function ( options ) {
1916
+ Rollbar . prototype . global = function ( options ) {
1906
1917
Rollbar . rateLimiter . configureGlobal ( options ) ;
1907
1918
return this ;
1908
1919
} ;
1909
1920
1910
- Rollbar . prototype . configure = function ( options , payloadData ) {
1921
+ Rollbar . prototype . configure = function ( options , payloadData ) {
1911
1922
var oldOptions = this . options ;
1912
1923
var payload = { } ;
1913
1924
if ( payloadData ) {
1914
- payload = { payload : payloadData } ;
1925
+ payload = { payload : payloadData } ;
1915
1926
}
1927
+
1916
1928
this . options = _ . merge ( oldOptions , options , payload ) ;
1929
+
1930
+ // This must happen before the Notifier is configured
1931
+ var tracer = this . options . tracer || null ;
1932
+ if ( validateTracer ( tracer ) ) {
1933
+ this . tracer = tracer ;
1934
+ // set to a string for api response serialization
1935
+ this . options . tracer = 'opentracing-tracer-enabled' ;
1936
+ this . options . _configuredOptions . tracer = 'opentracing-tracer-enabled' ;
1937
+ } else {
1938
+ this . tracer = null ;
1939
+ }
1940
+
1917
1941
this . notifier && this . notifier . configure ( this . options ) ;
1918
1942
this . telemeter && this . telemeter . configure ( this . options ) ;
1919
1943
setStackTraceLimit ( options ) ;
1920
1944
this . global ( this . options ) ;
1945
+
1946
+ if ( validateTracer ( options . tracer ) ) {
1947
+ this . tracer = options . tracer
1948
+ }
1949
+
1921
1950
return this ;
1922
1951
} ;
1923
1952
1924
- Rollbar . prototype . log = function ( item ) {
1953
+ Rollbar . prototype . log = function ( item ) {
1925
1954
var level = this . _defaultLogLevel ( ) ;
1926
1955
return this . _log ( level , item ) ;
1927
1956
} ;
1928
1957
1929
- Rollbar . prototype . debug = function ( item ) {
1958
+ Rollbar . prototype . debug = function ( item ) {
1930
1959
this . _log ( 'debug' , item ) ;
1931
1960
} ;
1932
1961
1933
- Rollbar . prototype . info = function ( item ) {
1962
+ Rollbar . prototype . info = function ( item ) {
1934
1963
this . _log ( 'info' , item ) ;
1935
1964
} ;
1936
1965
1937
- Rollbar . prototype . warn = function ( item ) {
1966
+ Rollbar . prototype . warn = function ( item ) {
1938
1967
this . _log ( 'warning' , item ) ;
1939
1968
} ;
1940
1969
1941
- Rollbar . prototype . warning = function ( item ) {
1970
+ Rollbar . prototype . warning = function ( item ) {
1942
1971
this . _log ( 'warning' , item ) ;
1943
1972
} ;
1944
1973
1945
- Rollbar . prototype . error = function ( item ) {
1974
+ Rollbar . prototype . error = function ( item ) {
1946
1975
this . _log ( 'error' , item ) ;
1947
1976
} ;
1948
1977
1949
- Rollbar . prototype . critical = function ( item ) {
1978
+ Rollbar . prototype . critical = function ( item ) {
1950
1979
this . _log ( 'critical' , item ) ;
1951
1980
} ;
1952
1981
1953
- Rollbar . prototype . wait = function ( callback ) {
1982
+ Rollbar . prototype . wait = function ( callback ) {
1954
1983
this . queue . wait ( callback ) ;
1955
1984
} ;
1956
1985
1957
- Rollbar . prototype . captureEvent = function ( type , metadata , level ) {
1986
+ Rollbar . prototype . captureEvent = function ( type , metadata , level ) {
1958
1987
return this . telemeter . captureEvent ( type , metadata , level ) ;
1959
1988
} ;
1960
1989
1961
- Rollbar . prototype . captureDomContentLoaded = function ( ts ) {
1990
+ Rollbar . prototype . captureDomContentLoaded = function ( ts ) {
1962
1991
return this . telemeter . captureDomContentLoaded ( ts ) ;
1963
1992
} ;
1964
1993
1965
- Rollbar . prototype . captureLoad = function ( ts ) {
1994
+ Rollbar . prototype . captureLoad = function ( ts ) {
1966
1995
return this . telemeter . captureLoad ( ts ) ;
1967
1996
} ;
1968
1997
1969
- Rollbar . prototype . buildJsonPayload = function ( item ) {
1998
+ Rollbar . prototype . buildJsonPayload = function ( item ) {
1970
1999
return this . api . buildJsonPayload ( item ) ;
1971
2000
} ;
1972
2001
1973
- Rollbar . prototype . sendJsonPayload = function ( jsonPayload ) {
2002
+ Rollbar . prototype . sendJsonPayload = function ( jsonPayload ) {
1974
2003
this . api . postJsonPayload ( jsonPayload ) ;
1975
2004
} ;
1976
2005
1977
2006
/* Internal */
1978
2007
1979
- Rollbar . prototype . _log = function ( defaultLevel , item ) {
2008
+ Rollbar . prototype . _log = function ( defaultLevel , item ) {
1980
2009
var callback ;
1981
2010
if ( item . callback ) {
1982
2011
callback = item . callback ;
@@ -1991,6 +2020,7 @@ Rollbar.prototype._log = function(defaultLevel, item) {
1991
2020
return ;
1992
2021
}
1993
2022
try {
2023
+ this . _addTracingInfo ( item ) ;
1994
2024
item . level = item . level || defaultLevel ;
1995
2025
this . telemeter . _captureRollbarItem ( item ) ;
1996
2026
item . telemetryEvents = this . telemeter . copyEvents ( ) ;
@@ -2000,11 +2030,11 @@ Rollbar.prototype._log = function(defaultLevel, item) {
2000
2030
}
2001
2031
} ;
2002
2032
2003
- Rollbar . prototype . _defaultLogLevel = function ( ) {
2033
+ Rollbar . prototype . _defaultLogLevel = function ( ) {
2004
2034
return this . options . logLevel || 'debug' ;
2005
2035
} ;
2006
2036
2007
- Rollbar . prototype . _sameAsLastError = function ( item ) {
2037
+ Rollbar . prototype . _sameAsLastError = function ( item ) {
2008
2038
if ( ! item . _isUncaught ) {
2009
2039
return false ;
2010
2040
}
@@ -2017,6 +2047,34 @@ Rollbar.prototype._sameAsLastError = function(item) {
2017
2047
return false ;
2018
2048
} ;
2019
2049
2050
+ Rollbar . prototype . _addTracingInfo = function ( item ) {
2051
+ // Tracer validation occurs in the constructor
2052
+ // or in the Rollbar.prototype.configure methods
2053
+ if ( this . tracer ) {
2054
+ // add rollbar occurrence uuid to span
2055
+ var span = this . tracer . scope ( ) . active ( ) ;
2056
+
2057
+ if ( validateSpan ( span ) ) {
2058
+ span . setTag ( 'rollbar.error_uuid' , item . uuid ) ;
2059
+ span . setTag ( 'rollbar.has_error' , true ) ;
2060
+
2061
+ // add span ID & trace ID to occurrence
2062
+ var opentracingSpanId = span . context ( ) . toSpanId ( ) ;
2063
+ var opentracingTraceId = span . context ( ) . toTraceId ( ) ;
2064
+
2065
+ if ( item . custom ) {
2066
+ item . custom . opentracing_span_id = opentracingSpanId ;
2067
+ item . custom . opentracing_trace_id = opentracingTraceId ;
2068
+ } else {
2069
+ item . custom = {
2070
+ opentracing_span_id : opentracingSpanId ,
2071
+ opentracing_trace_id : opentracingTraceId
2072
+ } ;
2073
+ }
2074
+ }
2075
+ }
2076
+ }
2077
+
2020
2078
function generateItemHash ( item ) {
2021
2079
var message = item . message || '' ;
2022
2080
var stack = ( item . err || { } ) . stack || String ( item . err ) ;
@@ -2032,6 +2090,51 @@ function setStackTraceLimit(options) {
2032
2090
}
2033
2091
}
2034
2092
2093
+ /**
2094
+ * Validate the Tracer object provided to the Client
2095
+ * is valid for our Opentracing use case.
2096
+ * @param {opentracer.Tracer } tracer
2097
+ */
2098
+ function validateTracer ( tracer ) {
2099
+ if ( ! tracer ) {
2100
+ return false ;
2101
+ }
2102
+
2103
+ if ( ! tracer . scope || typeof tracer . scope !== 'function' ) {
2104
+ return false ;
2105
+ }
2106
+
2107
+ const scope = tracer . scope ( ) ;
2108
+
2109
+ if ( ! scope || ! scope . active || typeof scope . active !== 'function' ) {
2110
+ return false ;
2111
+ }
2112
+
2113
+ return true ;
2114
+ }
2115
+
2116
+ /**
2117
+ * Validate the Span object provided
2118
+ * @param {opentracer.Span } span
2119
+ */
2120
+ function validateSpan ( span ) {
2121
+ if ( ! span || ! span . context || typeof span . context !== 'function' ) {
2122
+ return false ;
2123
+ }
2124
+
2125
+ const spanContext = span . context ( ) ;
2126
+
2127
+ if ( ! spanContext
2128
+ || ! spanContext . toSpanId
2129
+ || ! spanContext . toTraceId
2130
+ || typeof spanContext . toSpanId !== 'function'
2131
+ || typeof spanContext . toTraceId !== 'function' ) {
2132
+ return false
2133
+ }
2134
+
2135
+ return true ;
2136
+ }
2137
+
2035
2138
module . exports = Rollbar ;
2036
2139
2037
2140
@@ -4339,7 +4442,8 @@ function addBaseInfo(item, options, callback) {
4339
4442
notifier : {
4340
4443
name : 'rollbar-browser-js' ,
4341
4444
version : options . version
4342
- }
4445
+ } ,
4446
+ custom : item . custom
4343
4447
} ) ;
4344
4448
callback ( null , item ) ;
4345
4449
}
0 commit comments