Skip to content

Commit 7d41215

Browse files
committedFeb 1, 2015
btrace blog initial changes
1 parent 6f00f9a commit 7d41215

15 files changed

+237
-187
lines changed
 

‎_includes/header.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
<ul class="nav navbar-nav">
3030
<li class="active"><a href="{{ site.baseurl }}/">Home</a></li>
3131
<li class="active visible-xs-block"><a href="{{ site.baseurl }}/links.html">Links</a></li>
32+
<li class="active"><a href="{{ site.baseurl }}/downloads.html">Downloads</a></li>
33+
<!--<li class="active"><a href="{{ site.baseurl }}/about.html">About</a></li>-->
3234
<li class="active"><a href="{{ site.baseurl }}/archive.html">Archive</a></li>
33-
<li class="active"><a href="{{ site.baseurl }}/about.html">About</a></li>
3435
<li class="active"><a href="{{ site.baseurl }}/feed.xml">RSS</a></li>
3536
{% if site.github != '' %}
3637
<li class="active"><a href="https://github.com/{{ site.github }}">Github</a></li>

‎_includes/links-list.html

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<h1>Links</h1>
22
<ul>
3-
<li><a href="#">One</a></li>
4-
<li><a href="#">Two</a></li>
5-
<li><a href="#">Three</a></li>
6-
<li><a href="#">Four</a></li>
3+
<li><a href="#">None yet</a></li>
74
</ul>

‎_layouts/default.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
<div class="container container-left">
44
<div class="row">
5-
<div class="col-md-3 hidden-xs">
6-
{% include sidebar.html %}
7-
</div>
85
<div class="col-md-9">
96
{{ content }}
107
</div>
8+
<div class="col-md-3 hidden-xs">
9+
{% include sidebar.html %}
10+
</div>
1111
</div>
1212
</div>
1313

‎_posts/2012-05-22-Vivamus-porttitor-porta-tortor.md

-12
This file was deleted.

‎_posts/2013-05-22-Nulla-vel-risus-dapibus.md

-12
This file was deleted.

‎_posts/2013-06-22-Cum-sociis-natoque-penatibus.md

-12
This file was deleted.

‎_posts/2014-06-22-Maecenas-feugiat-fringilla-nibh.md

-12
This file was deleted.

‎_posts/2014-07-22-Lorem-ipsum-dolor-sit-amet.md

-12
This file was deleted.

‎_posts/2014-08-22-jekyll-clean-theme.md

-90
This file was deleted.
+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
layout: post
3+
title: "Extensible Services for BTrace"
4+
date: 2014-09-10 20:00:00 +0100
5+
comments: false
6+
---
7+
8+
# History
9+
10+
The ability to extend **BTrace** with plugins to overcome the limits imposed by its safety guarantees while still not allowing to inject any arbitrary code was requested a long time ago and is tracked as [BTRACE-64](https://github.com/jbachorik/btrace/issues/29)
11+
12+
# Solution, round 1
13+
14+
The first attempt to address this problem brought many problems that were supposed to be solved by a more-or-less complete engine rewrite in **BTrace 2.0**. In order to make the system really extensible the modularity was baked-in to all its parts - it was possible to even extend the internal communication protocol with custom messages. 
15+
16+
All of this came at a price, though. It was paid by extra nano- and micro-seconds spent in the BTrace runtime jumping through all those indirection levels.
17+
18+
Despite the availability of the [**BTrace 2.0 Preview** builds](https://kenai.com/projects/btrace/forums/forum/topics/523919-BTrace-2) for quite a long time there was almost no reaction from the community. This would indicate that the *“rewrite from scratch”* approach is a deal-breaker for the majority of the users.
19+
20+
# Rewind, Round 2
21+
22+
## Sketchup
23+
24+
Instead of rewriting the engine from scratch it seems to be possible to go the way of gradual changes and improvements.
25+
26+
The main goal is to allow the users to write application specific extensions for **BTrace** which can be easily used just by having them on the classpath.
27+
28+
Eg. the following invocation will allow to use any **BTrace** extensions available in the *path_to_my_extension.jar* archive. A class is considered to be an extension if it extends a **BTrace** extension base class (eg. *com.sun.btrace.services.spi.SimpleService*)
29+
30+
## How to Use
31+
32+
The following command would instruct **BTrace** to pickup the extensions jar.
33+
34+
`btrace -cp ...:<path_to_my_extension.jar> <pid> <tracing script>`
35+
36+
In order to use an extension one would do 
37+
38+
39+
``` java
40+
@OnMethod(....)
41+
public static void handler(...) {  
42+
// the following statement will inject the runtime 
43+
// aware service "Printer" 
44+
@Injected Printer p = Service.runtime(Printer.class);   
45+
p.println("hello");
46+
}
47+
48+
```
49+
50+
51+
As one can see it is not that different to what one was used to do before. 
52+
53+
## Why All This Fuzz
54+
55+
### DSL(?) Mess Cleanup
56+
57+
Let’s face it. **BTraceUtils** is a dump right now. It contains any and all functions one might think as being useful when writing BTrace scripts. As the result it is rather difficult to locate the method one actually wants to use.
58+
59+
The extensions will allow for off-loading specific features of **BTraceUtils** leaving there only methods comprising the actual **DSL** (well, I might even rename the class to something more meaningful)
60+
61+
### Integration with External Systems
62+
63+
Right now **BTrace** is pretty limited in how it can export the collected data - it can either write it to file or stdout. While this is sufficient for one-off scripts it is not the first choice when one wants to include **BTrace** in more complex systems (eg. acting as a data provider for [Riemann](http://riemann.io/)).
64+
65+
### Performance
66+
67+
This implementation, in addition to not causing any performance regression, can even provide slight improvements for the runtime aware services like **Printer**. Each invocation of *print*/*println* will use the cached runtime as opposed to looking it up when using **BTraceUtils** (not using services). 

‎_posts/2014-11-13-services-final.md

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
layout: post
3+
title: "BTrace Services (Final Proposal)"
4+
date: 2014-11-13 20:00:00 +0100
5+
comments: false
6+
---
7+
8+
In my previous [blog post](2014/09/extensible-services) I was sketching up a possible solution to **BTrace** extensibility.
9+
10+
A few experiments with AST and bytecode verifiers later I came up with a relatively easy way to provide the extensibility of the core **BTrace** functionality by the means of external plugins. Very importantly, introducing external plugins doesn’t incur any additional overhead on top of the one caused by the extension functionality itself.
11+
12+
# Creating a New Service
13+
14+
Creating a new service is just a matter of extending one of the following two classes
15+
16+
* com.sun.btrace.services.spi.SimpleService
17+
* com.sun.btrace.services.spi.RuntimeService
18+
19+
20+
## SimpleService
21+
22+
A stateless service which can even be a singleton. It has no access to the **BTrace** runtime and can rely on the provided values.
23+
24+
## RuntimeService
25+
26+
For each **BTraceRuntime** a new service instance will be created. The service can use **BTrace** features exposed via **BTraceRuntime** - eg. send messages over the wire channel.
27+
28+
## Using Services
29+
30+
Services become available by adding the jars containing them to the bootclasspath. (eg. via [agent options](https://github.com/jbachorik/btrace/wiki#starting-application-with-btrace))
31+
32+
The recommended way to use services in the script is to create fields of the appropriate service type and annotate them by the **@Injected** annotation.
33+
34+
35+
```java
36+
@BTrace public class MyTrace {
37+
// a simple service instantiated via the default noarg constructor
38+
@Injected private static MyService svc;
39+
40+
// a simple service instantiated via the given static method
41+
@Injected(factoryMethod = "singleton") private static MyService svc1;
42+
43+
// a runtime-aware service instantiated via the default single arg (*BTraceRuntime*) constructor
44+
@Injected(ServiceType.RUNTIME) private static RtService svc2;
45+
46+
@OnMethod(....)
47+
public static void interceptMethod(...) {
48+
svc.process(...);
49+
svc1.process(...);
50+
svc2.process(...);
51+
}
52+
}
53+
54+
```
55+
56+
There is an alternative approach valid only for locally accessible services.
57+
58+
```java
59+
@OnMethod(...)
60+
public void handler(...) {
61+
// a simple service instantiated via the default noarg constructor
62+
MyService svc = Service.simple(MyService.class);
63+
64+
// a simple service instantiated via the given static method
65+
MyService svc1 = Service.simple("singleton", MyService.class)
66+
67+
// a runtime-aware service instantiated via the default single arg (*BTraceRuntime*) constructor
68+
RtService svc2 = Service.runtime(RtService.classs);
69+
70+
svc.process(...);
71+
svc1.process(...);
72+
svc2.process(...);
73+
}
74+
```
75+
76+
These two approaches are functionally equivalent - it really depends on the script author which one she should choose.
77+
78+
# Planning
79+
80+
This functionality is planned for the upcoming version 1.3 of **BTrace**.
81+
82+
Integration is tracked by this [pull request](https://github.com/jbachorik/btrace/pull/98)

‎css/theme.css

+26-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@ body {
2424
color: #428bca;
2525
}
2626

27+
.sidebar ul {
28+
margin-top: -0.5em;
29+
}
30+
2731
.sidebar li {
2832
margin-top: .7em;
33+
margin-left: -1em;
2934
line-height: 1em;
3035
}
3136

@@ -38,8 +43,27 @@ body {
3843
}
3944

4045
.well h1 {
41-
color: #ee4444;
42-
font-size: 1.3em;
46+
margin-top: -0.1em;
47+
color: #7891b3;
48+
font-size: 1.6em;
49+
}
50+
51+
.well h2 {
52+
margin-top: -0.1em;
53+
color: #7891b3;
54+
font-size: 1.4em;
55+
}
56+
57+
.well h3 {
58+
margin-top: -0.1em;
59+
color: #7891b3;
60+
font-size: 1.2em;
61+
}
62+
63+
.well h4 {
64+
margin-top: -0.1em;
65+
color: #7891b3;
66+
font-size: 1.0em;
4367
}
4468

4569
.author {

‎downloads.html

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
layout: default
3+
---
4+
5+
<div class="article">
6+
<h1>Downloads</h1>
7+
<div class="well">
8+
<h1>1.3-snapshot</h1>
9+
<ul>
10+
<li><a href="http://dl.bintray.com/jbachorik/snapshots/btrace/1.3/btrace-bin.zip">btrace-bin.zip</a></li>
11+
<li><a href="http://dl.bintray.com/jbachorik/snapshots/btrace/1.3/btrace-bin.tar.gz">btrace-bin.tar.gz</a></li>
12+
</ul>
13+
</div>
14+
</div>

‎feed.xml

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
---
2-
layout: none
2+
layout: null
33
---
44

55
<?xml version="1.0" encoding="UTF-8"?>
66
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
7-
<channel>
8-
<title>{{ site.name }}</title>
9-
<description>{{ site.description }}</description>
10-
<link>{{ site.baseurl}}{{ site.url }}</link>
11-
<atom:link href="{{ site.baseurl}}{{ site.url }}/feed.xml" rel="self" type="application/rss+xml" />
12-
{% for post in site.posts limit:10 %}
13-
<item>
14-
<title>{{ post.title }}</title>
15-
<description>{{ post.content | xml_escape }}</description>
16-
<pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate>
17-
<link>{{ site.url }}{{ site.baseurl}}{{ post.url }}</link>
18-
<guid isPermaLink="true">{{ site.url }}{{ site.baseurl}}{{ post.url }}</guid>
19-
</item>
20-
{% endfor %}
21-
</channel>
7+
<channel>
8+
<title>{{ site.name }}</title>
9+
<description>{{ site.description }}</description>
10+
<link>{{ site.baseurl}}{{ site.url }}</link>
11+
<atom:link href="{{ site.baseurl}}{{ site.url }}/feed.xml" rel="self" type="application/rss+xml" />
12+
{% for post in site.posts limit:10 %}
13+
<item>
14+
<title>{{ post.title }}</title>
15+
<description>{{ post.content | xml_escape }}</description>
16+
<pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate>
17+
<link>{{ site.url }}{{ site.baseurl}}{{ post.url }}</link>
18+
<guid isPermaLink="true">{{ site.url }}{{ site.baseurl}}{{ post.url }}</guid>
19+
</item>
20+
{% endfor %}
21+
</channel>
2222
</rss>

‎index.html

+26-11
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,27 @@
22
layout: default
33
---
44

5+
<div class="article">
6+
<div class="well">
7+
<h1>BTrace - a safe, dynamic tracing tool for the Java platform</h1>
8+
<div style="font-size: larger">BTrace is a safe, dynamic tracing tool for the Java platform.</div>
9+
10+
BTrace can be used to dynamically trace a running Java program
11+
(similar to DTrace for OpenSolaris applications and OS).
12+
BTrace dynamically instruments the classes of the target
13+
application to inject tracing code ("bytecode tracing").
14+
{% if site.github != '' %}
15+
<a href="https://github.com/{{ site.github }}/wiki">[more]</a>
16+
{% endif %}
17+
</div>
18+
</div>
19+
520
{% for post in paginator.posts %}
621
<div class="article">
722
<div class="well">
823
<h1><a href="{{ site.baseurl}}{{ post.url }}">{{ post.date | date: "%b %-d, %Y" }} - {{ post.title }}</a></h1>
924
{% if site.comments == true and post.comments == true and site.disqus != '' %}
10-
<p class="author"><a href="{{ site.baseurl }}{{ post.url }}/#disqus_thread">Comments</a></p>
25+
<p class="author"><a href="{{ site.baseurl }}{{ post.url }}/#disqus_thread">Comments</a></p>
1126
{% endif %}
1227
<div class="content">
1328
{{ post.content }}
@@ -17,15 +32,15 @@ <h1><a href="{{ site.baseurl}}{{ post.url }}">{{ post.date | date: "%b %-d, %Y"
1732
{% endfor %}
1833

1934
<div class="pagination">
20-
{% if paginator.previous_page %}
21-
{% if paginator.previous_page == 1 %}
22-
<a class="btn btn-default" href="{{ site.baseurl}}/index.html" class="previous">Newer</a>
23-
{% else %}
24-
<a class="btn btn-default" href="{{ site.baseurl}}/page{{ paginator.previous_page }}" class="previous">Newer</a>
25-
{% endif %}
26-
{% endif %}
27-
<span class="page_number ">Page: {{ paginator.page }} of {{ paginator.total_pages }}</span>
28-
{% if paginator.next_page %}
35+
{% if paginator.previous_page %}
36+
{% if paginator.previous_page == 1 %}
37+
<a class="btn btn-default" href="{{ site.baseurl}}/index.html" class="previous">Newer</a>
38+
{% else %}
39+
<a class="btn btn-default" href="{{ site.baseurl}}/page{{ paginator.previous_page }}" class="previous">Newer</a>
40+
{% endif %}
41+
{% endif %}
42+
<span class="page_number ">Page: {{ paginator.page }} of {{ paginator.total_pages }}</span>
43+
{% if paginator.next_page %}
2944
<a class="btn btn-default" href="{{ site.baseurl}}/page{{ paginator.next_page }}" class="next">Older</a>
30-
{% endif %}
45+
{% endif %}
3146
</div>

0 commit comments

Comments
 (0)
Please sign in to comment.